#ifndef _MSG_MANAGER_H_
#define _MSG_MANAGER_H_

#include "stdint.h"
#include "stdbool.h"
#include "freertos/FreeRTOS.h"
#include "mailbox.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef enum
{
	MSG_NULL = 0,

	MSG_START_APP ,
	MSG_SWITCH_APP,
	MSG_INIT_APP,
	MSG_EXIT_APP,

	MSG_KEY_INPUT,
	MSG_INPUT_EVENT,
	MSG_UI_EVENT,
	MSG_TTS_EVENT,
	MSG_HOTPLUG_EVENT,
	MSG_VOLUME_CHANGED_EVENT,

	MSG_POWER_OFF,
	MSG_STANDBY,
	MSG_LOW_POWER,
	MSG_NO_POWER,
	MSG_REBOOT,

    /* sync message no replay */
	MSG_REPLY_NO_REPLY,

	/* message process success */
	MSG_REPLY_SUCCESS,

	/* message process failed */
	MSG_REPLY_FAILED,

	MSG_BAT_CHARGE_EVENT,
	MSG_SR_INPUT,
	MSG_FACTORY_DEFAULT,
	MSG_START_RECONNECT,
	MSG_ENTER_PAIRING_MODE,
	MSG_WIFI_DISCONNECT,
	MSG_RETURN_TO_CALLER,

	MSG_BT_EVENT,

	MSG_BT_ENGINE_READY,

	MSG_SHUT_DOWN,

	MSG_BT_REMOTE_VOL_SYNC,

	MSG_SYS_EVENT,

	MSG_SYS_WAKEUP,
	MSG_BT_PHONE_LIST_CLEAR,
	MSG_BT_TWS_LIST_CLEAR,

	MSG_CLEAR_PAIR_LIST,

	/* service defined message */
	MSG_SRV_MESSAGE_START           = 128,

	/* application defined message */
	MSG_APP_MESSAGE_START           = 200,
} msg_type;

bool msg_manager_send_async_msg(char* receiver, struct app_msg *msg);
bool msg_manager_send_sync_msg(char *receiver, struct app_msg *msg, struct app_msg **response);
bool msg_manager_receive_msg(struct app_msg** msg, int timeout);
bool msg_manager_receive_exit(struct app_msg *msg);
bool msg_manager_init(void);
bool msg_manager_deinit(void);

#ifdef __cplusplus
}
#endif

#endif /* _MSG_MANAGER_H_ */